global datapath "~/DataFolder"
global Analyses "~/Results"

**************************************************** Table 12: Financial Crisis
use "$datapath/RegData.dta", clear

*Use Specialization measured in year 2003
gen Spec0 = spec_above5pctemp if year == 2003
bys bank_county: egen Spec = mean(Spec0)
drop if missing(Spec)

*Event Windows 
keep if year>=2004 & year<=2010
gen Post = year > 2007
tabulate year

gen Pre4 = year == 2004
gen Pre3 = year == 2005
gen Pre2 = year == 2006
gen Pre1 = year == 2007

gen Post1 = year == 2008
gen Post2 = year == 2009
gen Post3 = year == 2010

*Regressions
reghdfe num c.Spec##c.Post riskiness male avg_minority branch distance numsbl lretain size loan deposit p_ci p_re roa liquid,absorb(county_year bank_state bank_year) cluster(fips)
outreg2 using Table12.xls, replace label dec(3) drop(num) nor2 stats(coef se) addstat(Adjusted R-squared,e(r2_a)) addtext(County*Year FE, Yes, Bank*State FE, Yes, Bank*Year FE, Yes) 

reghdfe num c.Spec#c.Pre4 c.Spec#c.Pre3 c.Spec#c.Pre2 Spec c.Spec#c.Post1 c.Spec#c.Post2 c.Spec#c.Post3 riskiness male avg_minority branch distance numsbl lretain size loan deposit p_ci p_re roa liquid, absorb(county_year bank_state bank_year) cluster(fips)
outreg2 using Table12.xls, append label dec(3) drop(num) nor2 stats(coef se) addstat(Adjusted R-squared,e(r2_a)) addtext(County*Year FE, Yes, Bank*State FE, Yes, Bank*Year FE, Yes) 	
	
reghdfe volume c.Spec##c.Post riskiness male avg_minority branch distance numsbl lretain size loan deposit p_ci p_re roa liquid, absorb(county_year bank_state bank_year) cluster(fips)
outreg2 using Table12.xls, append label dec(3) drop(volume) nor2 stats(coef se) addstat(Adjusted R-squared,e(r2_a)) addtext(County*Year FE, Yes, Bank*State FE, Yes, Bank*Year FE, Yes) 

reghdfe volume c.Spec#c.Pre4 c.Spec#c.Pre3 c.Spec#c.Pre2 Spec c.Spec#c.Post1 c.Spec#c.Post2 c.Spec#c.Post3 riskiness male avg_minority branch distance numsbl lretain size loan deposit p_ci p_re roa liquid, absorb(county_year bank_state bank_year) cluster(fips)
outreg2 using Table12.xls, append label dec(3) drop(volume) nor2 stats(coef se) addstat(Adjusted R-squared,e(r2_a)) addtext(County*Year FE, Yes, Bank*State FE, Yes, Bank*Year FE, Yes) 
	
	
	
	
